/*
*	Developed by Leonardo Chatain and Pedro Dusso, at Universidade Federal do Rio Grande do Sul, Brasil, 2009/1
*	Source available at glpacman.codeplex.com
*/

#pragma once
#ifndef _CHARACTER_H_
#define _CHARACTER_H_

#include "Point2D.h"
#include "Vector2D.h"
#include "Definitions.h"

class Character
{
public:
	enum Directions {
		up = 0,
		right,
		down,
		left
	};
protected:
	Point2D position;
	Vector2D direction;
	float heigthPosition;
	float linearSpeed;
	float angularSpeed;	
	Directions discreteDirection;
	Directions incomingDirection;
	Directions turningDirection;
	bool turning;

public:
	Character(void);
	virtual ~Character(void) { };
	
	//Specifies that character class is abstract
	void draw();
	//void turnLeft();
	//void turnRight();
	void walk();

	//Getters and Setters
	inline void setPosition(Point2D newPosition) { position = newPosition; }
	inline Point2D getPosition() { return position; }
	/*inline void setDirection(Vector2D newDirection) {
		direction = newDirection;
		direction.normalize();
	}*/
	inline Vector2D getDirection() { return direction; }
	inline void setLinearSpeed(float newLinearSpeed) { linearSpeed = newLinearSpeed; }
	inline float getLinearSpeed() { return linearSpeed; }
	inline void setAngularSpeed(float newAngularSpeed) { angularSpeed = newAngularSpeed; }
	inline float getAngularSpeed() { return angularSpeed; }
	inline void setDiscreteDirection(Directions d) {
		discreteDirection = d;
		if (discreteDirection == turningDirection)
			turning = false;
		else
			turning = true;

		switch(d) {
			case (int)(up):
				direction.setXY(UP);
				break;
			case (int)(left):
				direction.setXY(LEFT);
				break;
			case (int)(down):
				direction.setXY(DOWN);
				break;
			case (int)(right):
				direction.setXY(RIGHT);
				break;
		}
		turningDirection = d;
	}
	inline Directions getDiscreteDirection() { return discreteDirection; }
	inline bool isTurning() {
		if (discreteDirection == turningDirection)
			turning = false;
		else
			turning = true;
		return turning;
	}
	inline void setTurning(bool t) { turning = t; }
	inline void setX(float X) { position.setX(X); }
	inline void setY(float Y) { position.setY(Y); }
	inline void setXY(float X, float Y) { position.setXY(X, Y); }
	inline float getX() { return position.getX(); }
	inline float getY() { return position.getY(); }
	inline void setDirectionXY(float x, float y) {
		direction.setXY(x, y);
		direction.normalize();
	}

	inline void setIncomingDirection(Directions dir) { incomingDirection = dir; }
	inline Directions getIncomingDirection() { return incomingDirection; }
	inline Directions getTurningDirection() { return turningDirection; }
	inline void setTurningDirection(Directions d) {
		turningDirection = d;
		if (turningDirection != discreteDirection) {
			turning = true;
		}
		else
			turning = false;
			
	}
	inline float getHeigthPosition() { return heigthPosition; }
};

#endif